#!/bin/bash
#
# mountcifs - Unmounts samba-cifs filesystems
# -> convenience script to be called in the shutdown/reboot sequence of Ubuntu Dapper 
#    as K02umountcifs
# Written by Max Durden
# max.durden@gmail.com
#

start() {
echo "mountcifs: nothing to do!"
}

stop() {
echo "Unmounting samba-cifs filesystems..."
MOUNTED_CIFS_DIRS=`mount -t cifs| cut -d\  -f3`
MOUNTED_DIRS_ARRAY=($MOUNTED_CIFS_DIRS)
for i in ${!MOUNTED_DIRS_ARRAY[@]}
do
  umount -l ${MOUNTED_DIRS_ARRAY[i]}
done
}

status() {
echo "Mounted samba-cifs filesystems..."
mount -t cifs| cut -d\  -f3
}

restart() {
echo "restart ..."
start
}

reload() {
echo "start ..."
start
}

force_reload() {
echo "force-reload ..."
start
}

case $1 in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
reload)
reload
;;
force-reload)
force_reload
;;
*)
echo "Usage: mountcifs {start|stop|restart|reload|force-reload|status}"
;;
esac

exit 0
